package com.demo.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.shopcart.service.QuickShoppingService;


@Component
public class ScheduleTasks {
//    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    
    @Autowired
    private QuickShoppingService quickShoppingService;
    
    /**
     * @Scheduled(fixedRate = 5000)
     * 每5秒执行一次
     * @Scheduled(cron="...")
     * cron表达式
     * 
     * main application 加入 @EnableScheduling 注解 启动
     * 
     */
    //每分钟 提前将抢购商品置为抢购状态 将过期抢购恢复正常 将过期订单取消
    @Scheduled(cron="0 0/1 * * * ?")
    public void updateGoodsMode2() {
    	quickShoppingService.updateGoodsModeAndOrder();
    	quickShoppingService.updateGoodsMode2();
    	quickShoppingService.updateOrder();
    }
    
   
}